/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author Ahmed
 */
@Named(value = "configs")
@RequestScoped
public class Configs {

    private String id;
    private String password;
    private String host;

    public Configs() {
        initConfigs();
    }
    private String port;

    public String getId() {
       
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getHost() {
        
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPort() {
        
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    private void initConfigs() {
         try {
             System.out.println("getting properties");
            Context c = new InitialContext();
            Properties p = (Properties) c.lookup("MAILCONFIG");
            id = p.getProperty("id");
            password = p.getProperty("password");
            host = p.getProperty("host");
            port = p.getProperty("port");

        } catch (NamingException ex) {
            Logger.getLogger(Configs.class.getName()).log(Level.SEVERE, null, ex);
        }}

}
